Cof Structure Notes (some speculations):

This is a "first crack" at tabulating the properties of all COF files.  There are still a number of data elements I haven't deciphered.  If you see a pattern to any of these (or know of any file I missed), please post on the Phrozen Keep Animation Forum and I'll follow up on it.  Some of these identifications were posted by TeLaMoN on the CV website.

The main purpose of this table is to provide a way of identifying a COF file that is very similar to one you might need to assemble a custom animation, as in importing graphics from other games.  It is possible to take a COF file that has what you want except the right frame count, change the second byte, add or delete bytes from the flag and layer tables, and have a functioning animation.  But with all the unknown functions it is still trial and error.  When deleting flag table bytes, best to avoid any nonzero bytes.  

Byte 4: Always 20, except one deviant case (am\cof\amblxbow.cof).  This particular file has unusual numbers in all fields, and looks very different from other COFs in a hex editor.  I think it is a bad file, or a file used in a different manner than all other COFs.

Bytes 5-08, 9-12, 13-16, 17-20, 21-24, 25-28: These six groupings are arbitrary, based on the appearance of similar data.  All appear to be DWORDs with low byte first, so I grouped them that way.  I thought some of these numbers might be image and offset data, and may yet have some part in positioning...but they don't agree with any offsets I saw in CV5, or frame dimensions in a gif editor.  And yes, some cases don't fit the model.

File Table bytes: A COF file assembles DCC files into a composite image.  Here are encoded references 9 bytes long times number of layers.  The last four bytes are null-terminated strings with the codes for weapon class (listed in WeaponClass.txt, with a couple of additional ones).  The idea these entries form a file table is TeLaMoN's.

Flag Table bytes: a number of bytes equal to number of frames per direction.  Usually 00, I suspect the nonzero bytes indicate that something gamewise occurs on certain frames in the sequence and may be used for timing events.

Layer Table bytes: the remainder of the COF file consists of an array X layers wide by Y frames long, a function identified by TeLaMoN.  The order of layers may change throughout the table.  Since D2 animation uses sprites, this table would indicate which sprite is in the foreground.

